package com.zmn.oms.task.listener;

import com.alibaba.fastjson.JSON;
import com.zmn.manager.mq.annotation.AliyunMQHandler;
import com.zmn.manager.mq.annotation.AliyunMQListener;
import com.zmn.manager.mq.constant.MqTagConsts;
import com.zmn.oms.model.entity.work.OrderWorkLogChange;
import com.zmn.oms.zmn.business.interfaces.ins.InsOrderNotifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 类描述：保险单
 *
 * @author liuying
 * @date 2019/01/22 20:42
 */
@AliyunMQListener(topic = "${spring.mq.topic.oms}")
@Component
@Slf4j
public class InsOrderChangeListener {

    @Autowired
    private InsOrderNotifyService insOrderNotifyService;

    @AliyunMQHandler(tags = MqTagConsts.ZMN_TOPIC_OMS_CHANGE_ORDER_WORK_INS)
    public void onOrderChange(String message) {
        try {
            log.info("【按单保险】 recive message:{}", message);
            OrderWorkLogChange orderWorkLogChange = JSON.parseObject(message, OrderWorkLogChange.class);
            insOrderNotifyService.notify(orderWorkLogChange);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
